ViewDragHelper

(SESL variant) ViewDragHelper is a utility class for writing custom ViewGroups. It offers a number of useful operations and state tracking for allowing a user to drag and reposition views within their parent ViewGroup.

Types

Link copied to clipboard
abstract class Callback
A Callback is used as a communication channel with the ViewDragHelper back to the parent view using it.

Properties

Link copied to clipboard
Indicates that a check should occur along all axes
Link copied to clipboard
Indicates that a check should occur along the horizontal axis
Link copied to clipboard
Indicates that a check should occur along the vertical axis
Link copied to clipboard
val EDGE_ALL: Int = 15
Edge flag set indicating all edges should be affected.
Link copied to clipboard
val EDGE_BOTTOM: Int = 8
Edge flag indicating that the bottom edge should be affected.
Link copied to clipboard
val EDGE_LEFT: Int = 1
Edge flag indicating that the left edge should be affected.
Link copied to clipboard
val EDGE_RIGHT: Int = 2
Edge flag indicating that the right edge should be affected.
Link copied to clipboard
val EDGE_TOP: Int = 4
Edge flag indicating that the top edge should be affected.
Link copied to clipboard
A null/invalid pointer ID.
Link copied to clipboard
A view is currently being dragged.
Link copied to clipboard
val STATE_IDLE: Int = 0
A view is not currently being dragged or animating as a result of a fling/snap.
Link copied to clipboard
A view is currently settling into place as a result of a fling or predefined non-interactive motion.

Functions

Link copied to clipboard
open fun abort()
cancel, but also abort all motion in progress and snap to the end of any animation.
Link copied to clipboard
open fun cancel()
The result of a call to this method is equivalent to processTouchEvent receiving an ACTION_CANCEL event.
Link copied to clipboard
open fun captureChildView(@NonNull childView: @NonNull View, activePointerId: Int)
Capture a specific child view for dragging within the parent.
Link copied to clipboard
open fun checkTouchSlop(directions: Int): Boolean
Check if any pointer tracked in the current gesture has crossed the required slop threshold.
open fun checkTouchSlop(directions: Int, pointerId: Int): Boolean
Check if the specified pointer tracked in the current gesture has crossed the required slop threshold.
Link copied to clipboard
open fun continueSettling(deferCallbacks: Boolean): Boolean
Move the captured settling view by the appropriate amount for the current time.
Link copied to clipboard
@NonNull
open fun create(@NonNull forParent: @NonNull ViewGroup, @NonNull cb: @NonNull ViewDragHelper.Callback): @NonNull ViewDragHelper
@NonNull
open fun create(@NonNull forParent: @NonNull ViewGroup, sensitivity: Float, @NonNull cb: @NonNull ViewDragHelper.Callback): @NonNull ViewDragHelper
Factory method to create a new ViewDragHelper.
Link copied to clipboard
@Nullable
open fun findTopChildUnder(x: Int, y: Int): @Nullable View
Find the topmost child under the given point within the parent view's coordinate system.
Link copied to clipboard
open fun flingCapturedView(minLeft: Int, minTop: Int, maxLeft: Int, maxTop: Int)
Settle the captured view based on standard free-moving fling behavior.
Link copied to clipboard
Link copied to clipboard
@Nullable
open fun getCapturedView(): @Nullable View
Link copied to clipboard
Return the default size used for edge tracking.
Link copied to clipboard
open fun getEdgeSize(): Int
Return the size of an edge.
Link copied to clipboard
open fun getMinVelocity(): Float
Return the currently configured minimum velocity.
Link copied to clipboard
open fun getTouchSlop(): Int
Link copied to clipboard
open fun getViewDragState(): Int
Retrieve the current drag state of this helper.
Link copied to clipboard
Determine if the currently captured view is under the given point in the parent view's coordinate system.
Link copied to clipboard
open fun isEdgeTouched(edges: Int): Boolean
Check if any of the edges specified were initially touched in the currently active gesture.
open fun isEdgeTouched(edges: Int, pointerId: Int): Boolean
Check if any of the edges specified were initially touched by the pointer with the specified ID.
Link copied to clipboard
open fun isPointerDown(pointerId: Int): Boolean
Check if the given pointer ID represents a pointer that is currently down (to the best of the ViewDragHelper's knowledge).
Link copied to clipboard
open fun isViewUnder(@Nullable view: @Nullable View, x: Int, y: Int): Boolean
Determine if the supplied view is under the given point in the parent view's coordinate system.
Link copied to clipboard
open fun processTouchEvent(@NonNull ev: @NonNull MotionEvent)
Process a touch event received by the parent view.
Link copied to clipboard
@NonNull
open fun seslCreate(@NonNull forParent: @NonNull ViewGroup, sensitivity: Float, @NonNull cb: @NonNull ViewDragHelper.Callback): @NonNull ViewDragHelper
Factory method to create a new ViewDragHelper.
Link copied to clipboard
open fun seslSetUpdateOffsetLR(update: Boolean)
Sets whether to update the left and right offsets of the captured view during dragging and settling.
Link copied to clipboard
open fun setEdgeSize(@Px @IntRange(from = 0) size: Int)
Set the range in pixels along the edges of this view that will actively detect edge touches or drags if edge tracking is enabled.
Link copied to clipboard
open fun setEdgeTrackingEnabled(edgeFlags: Int)
Enable edge tracking for the selected edges of the parent view.
Link copied to clipboard
open fun setMinVelocity(minVel: Float)
Set the minimum velocity that will be detected as having a magnitude greater than zero in pixels per second.
Link copied to clipboard
open fun settleCapturedViewAt(finalLeft: Int, finalTop: Int): Boolean
Settle the captured view at the given (left, top) position.
Link copied to clipboard
open fun setTouchSlop(touchSlop: Int)
Link copied to clipboard
open fun shouldInterceptTouchEvent(@NonNull ev: @NonNull MotionEvent): Boolean
Check if this event as provided to the parent view's onInterceptTouchEvent should cause the parent to intercept the touch event stream.
Link copied to clipboard
open fun smoothSlideViewTo(@NonNull child: @NonNull View, finalLeft: Int, finalTop: Int): Boolean
open fun smoothSlideViewTo(@NonNull child: @NonNull View, finalLeft: Int, finalTop: Int, duration: Int, @Nullable interpolator: @Nullable Interpolator): Boolean
Animate the view child to the given (left, top) position.